#编译
icc Ex1_in.c -o Ex1_in;
icc Ex1_1.c -o Ex1_1;
icc -openmp Ex1_2.c -o Ex1_2;
mpicc Ex1_3.c -o Ex1_3;
#备份上次统计结果
mv out1.txt out1.bak;
mv out2.txt out2.bak;
mv out3.txt out3.bak;

#数据量为10000
rm -rf in.txt;
./Ex1_in 10000;
echo 10000 >> out1.txt;		#输出10000
{ time ./Ex1_1; } 2>> out1.txt;	#运行串行
echo 10000 >> out2.txt;
echo 10000 >> out3.txt;
for((i=1; i<= 8; i++));do
  export OMP_NUM_THREADS=$i;	#设置OpenMP的处理器数
  echo $i >> out2.txt;
  { time ./Ex1_2 $i; } 2>>out2.txt;		
  echo $i >> out3.txt;
  { time mpiexec -n $i ./Ex1_3; } 2>>out3.txt;
done;

#数据量为50000
rm -rf in.txt ;
./Ex1_in 50000;
echo 50000 >> out1.txt;
{ time ./Ex1_1; } 2>> out1.txt;
echo 50000 >> out2.txt;
#echo 50000 >> out3.txt;
for((i=1; i<= 8; i++));do
  export OMP_NUM_THREADS=$i;
  echo $i >> out2.txt;
  { time ./Ex1_2 $i; } 2>>out2.txt;
#  echo $i >> out3.txt;
#  { time mpiexec -n $i ./Ex1_3; } 2>>out3.txt;
done;

#数据量为100000
rm -rf in.txt ;
./Ex1_in 100000;
echo 100000 >> out1.txt;
{ time ./Ex1_1; } 2>> out1.txt;
echo 100000 >> out2.txt;
#echo 100000 >> out3.txt;
for((i=1; i<= 8; i++));do
  export OMP_NUM_THREADS=$i;
  echo $i >> out2.txt;
  { time ./Ex1_2 $i; } 2>>out2.txt;
#  echo $i >> out3.txt;
#  { time mpiexec -n $i ./Ex1_3; } 2>>out3.txt;
done;